package com.base.service.impl;

import java.util.List;

import com.base.bean.Cardseries;
import com.base.service.CardseriesService;
import com.common.util.AbstractManager;
import com.common.util.PagerModel;

public class CardseriesServiceImpl extends AbstractManager implements
		CardseriesService {

	public void addCardseries(Cardseries cardseries) {
		String hql = "select nvl(max(seriesno),0) from Cardseries";
		
		//set seriesno by assigned
		long seriesno = 0l;
//		List list = this.getHibernateTemplate().find(hql);
//		if(list != null && list.size() > 0)list.get(0) == null?0l:(Long)list.get(0);//
		seriesno = (Long) this.getHibernateTemplate().find(hql).get(0);
		seriesno += 1l;
		
		cardseries.setSeriesno(seriesno);
		this.getHibernateTemplate().save(cardseries);
	}

	@SuppressWarnings("unchecked")
	public List<Cardseries> findAllCardseries() {
		String hql = "from Cardseries";
		return this.getHibernateTemplate().find(hql);
	}

	public Cardseries findCardseries(long seriesno) {
		return (Cardseries) this.getHibernateTemplate().load(Cardseries.class, seriesno);
	}

	public PagerModel findCardseriesForPager() {
		String hql = "from Cardseries";
		return searchPaginated(hql);
	}

	public void removeCardseries(long seriesno) {
		Cardseries cardseries = null;
		cardseries = (Cardseries) this.getHibernateTemplate().load(Cardseries.class, seriesno);
		if(cardseries != null)
			this.getHibernateTemplate().delete(cardseries);
	}

	public void updateCardseries(Cardseries cardseries) {
		this.getHibernateTemplate().update(cardseries);
	}

}
